
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>YUI Library Examples: The YUI Global Object: YUI 2 in 3 &amp; Gallery Modules</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    	<link rel="stylesheet" type="text/css" href="../../assets/yui.css" >

<style>
    /*Supplemental CSS for the YUI distribution*/
    #custom-doc { width: 95%; min-width: 950px; }
    #pagetitle {background-image: url(../../assets/bg_hd.gif);}
/*    #pagetitle h1 {background-image: url(../../assets/title_h_bg.gif);}*/
</style>

<link rel="stylesheet" type="text/css" href="../../assets/dpSyntaxHighlighter.css">
<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="../../build/yui/yui-debug.js"></script>
<style id="styleoverrides">
#wrapper {
    margin: 2em;
    width: 550px;
}
#wrapper .status {
    border: 1px solid black;
    margin-top: .5em;
    padding: .5em;
}

#wrapper textarea {
    visibility: hidden;
}

.yui-skin-sam .yui-toolbar-container .yui-toolbar-save span.yui-toolbar-icon {
    background-image: url( assets/save.png );
    background-position: 3px 2px;
    left: 4px;
    top: 2px;
}
.yui-skin-sam .yui-toolbar-container .yui-toolbar-save-selected span.yui-toolbar-icon {
    background-image: url( assets/save.png );
    background-position: 3px 2px;
    left: 4px;
    top: 2px;
}

.yui-skin-sam .yui-toolbar-container .yui-toolbar-clear span.yui-toolbar-icon {
    background-image: url( assets/clear.png );
    background-position: 3px 2px;
    left: 4px;
    top: 2px;
}
.yui-skin-sam .yui-toolbar-container .yui-toolbar-clear-selected span.yui-toolbar-icon {
    background-image: url( assets/clear.png );
    background-position: 3px 2px;
    left: 4px;
    top: 2px;
}

.yui-skin-sam .yui-toolbar-container .yui-toolbar-reset span.yui-toolbar-icon {
    background-image: url( assets/reset.png );
    background-position: 3px 2px;
    left: 4px;
    top: 2px;
}
.yui-skin-sam .yui-toolbar-container .yui-toolbar-reset-selected span.yui-toolbar-icon {
    background-image: url( assets/reset.png );
    background-position: 3px 2px;
    left: 4px;
    top: 2px;
}

.yui-skin-sam #main .yui-toolbar-container .yui-toolbar-titlebar h2 {
    font-size: 100%;
    font-weight: bold;
}
.yui-skin-sam #main .yui-toolbar-container .yui-toolbar-titlebar h2 {
    color:#000000;
    font-size:100%;
    font-weight:bold;
    margin:0;
    padding:0.3em 1em;
    text-align:left;
}

.yui-skin-sam #main .yui-toolbar-container .yui-toolbar-group h3 {
    color:#808080;
    font-size:75%;
    margin:1em 0 0;
    padding-bottom:0;
    padding-left:0.25em;
    text-align:left;
    font-weight: bold;
}

</style>


</head>
<body id="yahoo-com" class="yui3-skin-sam  yui-skin-sam">
<div id="custom-doc" class="yui-t2">
<div id="hd">
	<div id="ygunav">
		<p>
            <em>
                <a href="http://developer.yahoo.com/yui/3/">YUI 3.x Home</a> <i> - </i>	
            </em>
		</p>
		<form action="http://search.yahoo.com/search" id="sitesearchform">
            <input name="vs" type="hidden" value="developer.yahoo.com">
            <input name="vs" type="hidden" value="yuiblog.com">
			<input name="vs" type="hidden" value="yuilibrary.com">
		    <div id="sitesearch">
		    	<label for="searchinput">Site Search (YDN, YUILibrary &amp; YUIBlog): </label>
			    <input type="text" id="searchinput" name="p">
			    <input type="submit" value="Search" id="searchsubmit" class="ygbt">
		    </div>
		</form>
    </div>
	<div id="ygma"><a href="../../"><img src="../../assets/logo.gif"  border="0" width="200" height="93"></a></div>
	<div id="pagetitle"><h1>YUI Library Examples: The YUI Global Object: YUI 2 in 3 &amp; Gallery Modules</h1></div>
</div>
<div id="bd">


	<div id="yui-main">
		<div class="yui-b">
		  <div class="yui-ge">
			  <div class="yui-u first example" id="main">

	<h2>The YUI Global Object: YUI 2 in 3 &amp; Gallery Modules</h2>

	<div id="example" class="promo">
	<div class="example-intro">
	<p>This example demonstrates using YUI 2 with YUI 3 and a Gallery module.</p>
	</div>

	<div class="module example-container ">
			<div class="hd exampleHd">
			<p class="newWindowButton yui-skin-sam">
                <a href="yui-gallery2_clean.html" target="_blank">View example in new window.</a>
            </p>
		</div>		<div id="example-canvas" class="bd">

	
	<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

	

<div id="wrapper">
<textarea id="editor">This <strong>is a test</strong>, this is only a test.

</textarea>
<div class="status"> </div>
</div>

<script>


YUI({insertBefore: 'styleoverrides'}).use('node', 'event-delegate', 'yui2-editor', 'gallery-storage-lite', function(Y, result) {

    var YAHOO = Y.YUI2, res = Y.one('#wrapper .status'),
    defaultText = Y.one('#editor').get('value'),
    write = function(str) {
        var d = new Date();
        str += ' :: ' + d.toTimeString();
        res.setContent(str);
    },
    save = function() {
        Y.StorageLite.on('storage-lite:ready', function () {
            var html = editor.saveHTML();
            Y.StorageLite.setItem('editorContent', html);
            write('Editor content saved..');
        });
    };

    var editor = new YAHOO.widget.Editor('editor', {
        dompath: true,
        width: '550px',
        height: '250px',
        toolbar: {
            titlebar: 'Saving Editor',
            buttons: [
                { group: 'saveclear', label: 'Save & Clear',
                    buttons: [
                        { type: 'push', label: 'Save', value: 'save' },
                        { type: 'push', label: 'Clear', value: 'clear' },
                        { type: 'push', label: 'Reset', value: 'reset' }
                    ]
                },
                { group: 'textstyle', label: 'Font Style',
                    buttons: [
                        { type: 'push', label: 'Bold', value: 'bold' },
                        { type: 'push', label: 'Italic', value: 'italic' },
                        { type: 'push', label: 'Underline', value: 'underline' },
                        { type: 'separator' },
                        { type: 'select', label: 'Arial', value: 'fontname', disabled: true,
                            menu: [
                                { text: 'Arial', checked: true },
                                { text: 'Arial Black' },
                                { text: 'Comic Sans MS' },
                                { text: 'Courier New' },
                                { text: 'Lucida Console' },
                                { text: 'Tahoma' },
                                { text: 'Times New Roman' },
                                { text: 'Trebuchet MS' },
                                { text: 'Verdana' }
                            ]
                        },
                        { type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ], disabled: true },
                        { type: 'separator' },
                        { type: 'color', label: 'Font Color', value: 'forecolor', disabled: true },
                        { type: 'color', label: 'Background Color', value: 'backcolor', disabled: true }
                    ]
                }
            ]
        }
    });
    editor.on('toolbarLoaded', function() {
        editor.toolbar.on('clearClick', function() {
            editor.setEditorHTML('<br>');
            write('Editor content cleared..');
        });
        editor.toolbar.on('resetClick', function() {
            if (confirm('Are you sure you want to reset the Editor?')) {
                editor.setEditorHTML(defaultText);
                Y.StorageLite.setItem('editorContent', null);
                write('Editor content reset to default..');
            }
        });
        editor.toolbar.on('saveClick', save);
    });
    Y.later(5000, editor, function() {
        if (editor.editorDirty) {
            editor.editorDirty = null;
            save();
        }
    }, {}, true);

    Y.on('domready', function() {

        Y.StorageLite.on('storage-lite:ready', function () {
            var editorValue;
            try {
                editorValue = Y.StorageLite.getItem('editorContent');
            } catch(e) {}
            if (!editorValue) {
                Y.one('#editor').set('value', editorValue);
                write('Loaded editor content from Local Storage');
            } else {
                write('Loaded default editor content');
            }
            editor.render();
        });

    });


});

</script>

	<!--END SOURCE CODE FOR EXAMPLE =============================== -->

	
		</div>
	</div>
	</div>

	<h3>Setting it up</h3>

<p>This example uses the following modules: <code>node, gallery-storage-lite, yui2-editor</code></p>

<div id="syntax-08653b8922f1254e6f227ac37b16f844" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1">YUI<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="kw2">use</span><span class="br0">&#40;</span><span class="st0">'node'</span><span class="sy0">,</span> <span class="st0">'gallery-storage-lite'</span><span class="sy0">,</span> <span class="st0">'yui2-editor'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>Y<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">&nbsp;</div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;">YUI<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="kw2">use</span><span class="br0">&#40;</span><span class="st0">'node'</span><span class="sy0">,</span> <span class="st0">'gallery-storage-lite'</span><span class="sy0">,</span> <span class="st0">'yui2-editor'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>Y<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
&nbsp;</pre></div><textarea id="syntax-08653b8922f1254e6f227ac37b16f844-plain">YUI().use('node', 'gallery-storage-lite', 'yui2-editor', function(Y) {

});

</textarea></div>
<h3>Aliasing YUI 2</h3>
<p>For ease of use or for easier porting of code, this example aliases the <code>Y.YUI2</code> property on the instance to a local variable called <code>YAHOO</code>. 
This will allow most YUI 2 code to run unmodified.</p>

<div id="syntax-406b8b4d323fe723b0051b119921d698" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1">YUI<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="kw2">use</span><span class="br0">&#40;</span><span class="st0">'node'</span><span class="sy0">,</span> <span class="st0">'gallery-storage-lite'</span><span class="sy0">,</span> <span class="st0">'yui2-editor'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>Y<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">    <span class="co1">//Aliasing Y.YUI2 to YAHOO</span></div></li><li class="li1"><div class="de1">    <span class="kw2">var</span> YAHOO <span class="sy0">=</span> Y.<span class="me1">YUI2</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2"><span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp;</div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;">YUI<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="kw2">use</span><span class="br0">&#40;</span><span class="st0">'node'</span><span class="sy0">,</span> <span class="st0">'gallery-storage-lite'</span><span class="sy0">,</span> <span class="st0">'yui2-editor'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>Y<span class="br0">&#41;</span> <span class="br0">&#123;</span>
    <span class="co1">//Aliasing Y.YUI2 to YAHOO</span>
    <span class="kw2">var</span> YAHOO <span class="sy0">=</span> Y.<span class="me1">YUI2</span><span class="sy0">;</span>
&nbsp;
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
&nbsp;</pre></div><textarea id="syntax-406b8b4d323fe723b0051b119921d698-plain">YUI().use('node', 'gallery-storage-lite', 'yui2-editor', function(Y) {
    //Aliasing Y.YUI2 to YAHOO
    var YAHOO = Y.YUI2;

});

</textarea></div><h3>Full Source</h3>
<p>The rest of the example is just to show you that you can mix and match YUI 2 and YUI 3 code.</p>
<div id="syntax-d637e0fd7a315aab60d36f2178ced3cc" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1">YUI<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="kw2">use</span><span class="br0">&#40;</span><span class="st0">'node'</span><span class="sy0">,</span> <span class="st0">'gallery-storage-lite'</span><span class="sy0">,</span> <span class="st0">'yui2-editor'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>Y<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">    <span class="co1">//Aliasing Y.YUI2 to YAHOO</span></div></li><li class="li1"><div class="de1">    <span class="kw2">var</span> YAHOO <span class="sy0">=</span> Y.<span class="me1">YUI2</span><span class="sy0">,</span> res <span class="sy0">=</span> Y.<span class="me1">one</span><span class="br0">&#40;</span><span class="st0">'#wrapper .status'</span><span class="br0">&#41;</span><span class="sy0">,</span></div></li><li class="li2"><div class="de2">    defaultText <span class="sy0">=</span> Y.<span class="me1">one</span><span class="br0">&#40;</span><span class="st0">'#editor'</span><span class="br0">&#41;</span>.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">'value'</span><span class="br0">&#41;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">    <span class="kw1">write</span> <span class="sy0">=</span> <span class="kw2">function</span><span class="br0">&#40;</span>str<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">        <span class="kw2">var</span> d <span class="sy0">=</span> <span class="kw2">new</span> Date<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">        str <span class="sy0">+=</span> <span class="st0">' :: '</span> <span class="sy0">+</span> d.<span class="me1">toTimeString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">        res.<span class="me1">setContent</span><span class="br0">&#40;</span>str<span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">    <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">    save <span class="sy0">=</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">        Y.<span class="me1">StorageLite</span>.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'storage-lite:ready'</span><span class="sy0">,</span> <span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">            <span class="kw2">var</span> html <span class="sy0">=</span> editor.<span class="me1">saveHTML</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">            Y.<span class="me1">StorageLite</span>.<span class="me1">setItem</span><span class="br0">&#40;</span><span class="st0">'editorContent'</span><span class="sy0">,</span> html<span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">            <span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">'Editor content saved..'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">        <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">    <span class="br0">&#125;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">    <span class="kw2">var</span> editor <span class="sy0">=</span> <span class="kw2">new</span> YAHOO.<span class="me1">widget</span>.<span class="me1">Editor</span><span class="br0">&#40;</span><span class="st0">'editor'</span><span class="sy0">,</span> <span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">        dompath<span class="sy0">:</span> <span class="kw2">true</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">        width<span class="sy0">:</span> <span class="st0">'550px'</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">        height<span class="sy0">:</span> <span class="st0">'250px'</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">        toolbar<span class="sy0">:</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">            titlebar<span class="sy0">:</span> <span class="st0">'Saving Editor'</span><span class="sy0">,</span></div></li><li class="li2"><div class="de2">            buttons<span class="sy0">:</span> <span class="br0">&#91;</span></div></li><li class="li1"><div class="de1">                <span class="br0">&#123;</span> group<span class="sy0">:</span> <span class="st0">'saveclear'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Save &amp; Clear'</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                    buttons<span class="sy0">:</span> <span class="br0">&#91;</span></div></li><li class="li1"><div class="de1">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Save'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'save'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Clear'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'clear'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li2"><div class="de2">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Reset'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'reset'</span> <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">                    <span class="br0">&#93;</span></div></li><li class="li1"><div class="de1">                <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                <span class="br0">&#123;</span> group<span class="sy0">:</span> <span class="st0">'textstyle'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Font Style'</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                    buttons<span class="sy0">:</span> <span class="br0">&#91;</span></div></li><li class="li2"><div class="de2">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Bold'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'bold'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Italic'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'italic'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Underline'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'underline'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'separator'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'select'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Arial'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'fontname'</span><span class="sy0">,</span> disabled<span class="sy0">:</span> <span class="kw2">true</span><span class="sy0">,</span></div></li><li class="li2"><div class="de2">                            menu<span class="sy0">:</span> <span class="br0">&#91;</span></div></li><li class="li1"><div class="de1">                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Arial'</span><span class="sy0">,</span> checked<span class="sy0">:</span> <span class="kw2">true</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Arial Black'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Comic Sans MS'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Courier New'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li2"><div class="de2">                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Lucida Console'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Tahoma'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Times New Roman'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Trebuchet MS'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Verdana'</span> <span class="br0">&#125;</span></div></li><li class="li2"><div class="de2">                            <span class="br0">&#93;</span></div></li><li class="li1"><div class="de1">                        <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'spin'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'13'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'fontsize'</span><span class="sy0">,</span> range<span class="sy0">:</span> <span class="br0">&#91;</span> <span class="nu0">9</span><span class="sy0">,</span> <span class="nu0">75</span> <span class="br0">&#93;</span><span class="sy0">,</span> disabled<span class="sy0">:</span> <span class="kw2">true</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'separator'</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'color'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Font Color'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'forecolor'</span><span class="sy0">,</span> disabled<span class="sy0">:</span> <span class="kw2">true</span> <span class="br0">&#125;</span><span class="sy0">,</span></div></li><li class="li2"><div class="de2">                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'color'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Background Color'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'backcolor'</span><span class="sy0">,</span> disabled<span class="sy0">:</span> <span class="kw2">true</span> <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">                    <span class="br0">&#93;</span></div></li><li class="li1"><div class="de1">                <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">            <span class="br0">&#93;</span></div></li><li class="li1"><div class="de1">        <span class="br0">&#125;</span></div></li><li class="li2"><div class="de2">    <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">    editor.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'toolbarLoaded'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">        editor.<span class="me1">toolbar</span>.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'clearClick'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">            editor.<span class="me1">setEditorHTML</span><span class="br0">&#40;</span><span class="st0">'&lt;br&gt;'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">            <span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">'Editor content cleared..'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">        <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">        editor.<span class="me1">toolbar</span>.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'resetClick'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">            <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">confirm</span><span class="br0">&#40;</span><span class="st0">'Are you sure you want to reset the Editor?'</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">                editor.<span class="me1">setEditorHTML</span><span class="br0">&#40;</span>defaultText<span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">                Y.<span class="me1">StorageLite</span>.<span class="me1">setItem</span><span class="br0">&#40;</span><span class="st0">'editorContent'</span><span class="sy0">,</span> <span class="kw2">null</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">                <span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">'Editor content reset to default..'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">            <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">        <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">        editor.<span class="me1">toolbar</span>.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'saveClick'</span><span class="sy0">,</span> save<span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">    <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">    Y.<span class="me1">later</span><span class="br0">&#40;</span><span class="nu0">5000</span><span class="sy0">,</span> editor<span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">        <span class="kw1">if</span> <span class="br0">&#40;</span>editor.<span class="me1">editorDirty</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">            editor.<span class="me1">editorDirty</span> <span class="sy0">=</span> <span class="kw2">null</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">            save<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">        <span class="br0">&#125;</span></div></li><li class="li2"><div class="de2">    <span class="br0">&#125;</span><span class="sy0">,</span> <span class="br0">&#123;</span><span class="br0">&#125;</span><span class="sy0">,</span> <span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">    Y.<span class="me1">StorageLite</span>.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'storage-lite:ready'</span><span class="sy0">,</span> <span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">        <span class="kw2">var</span> editorValue <span class="sy0">=</span> Y.<span class="me1">StorageLite</span>.<span class="me1">getItem</span><span class="br0">&#40;</span><span class="st0">'editorContent'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">        <span class="kw1">if</span> <span class="br0">&#40;</span>editorValue <span class="sy0">!==</span> <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">            Y.<span class="me1">one</span><span class="br0">&#40;</span><span class="st0">'#editor'</span><span class="br0">&#41;</span>.<span class="me1">set</span><span class="br0">&#40;</span><span class="st0">'value'</span><span class="sy0">,</span> editorValue<span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">            <span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">'Loaded editor content from Local Storage'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">        <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">            <span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">'Loaded default editor content'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">        <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">        editor.<span class="me1">render</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">    <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp;</div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;">YUI<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="kw2">use</span><span class="br0">&#40;</span><span class="st0">'node'</span><span class="sy0">,</span> <span class="st0">'gallery-storage-lite'</span><span class="sy0">,</span> <span class="st0">'yui2-editor'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>Y<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
    <span class="co1">//Aliasing Y.YUI2 to YAHOO</span>
    <span class="kw2">var</span> YAHOO <span class="sy0">=</span> Y.<span class="me1">YUI2</span><span class="sy0">,</span> res <span class="sy0">=</span> Y.<span class="me1">one</span><span class="br0">&#40;</span><span class="st0">'#wrapper .status'</span><span class="br0">&#41;</span><span class="sy0">,</span>
    defaultText <span class="sy0">=</span> Y.<span class="me1">one</span><span class="br0">&#40;</span><span class="st0">'#editor'</span><span class="br0">&#41;</span>.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">'value'</span><span class="br0">&#41;</span><span class="sy0">,</span>
    <span class="kw1">write</span> <span class="sy0">=</span> <span class="kw2">function</span><span class="br0">&#40;</span>str<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">var</span> d <span class="sy0">=</span> <span class="kw2">new</span> Date<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        str <span class="sy0">+=</span> <span class="st0">' :: '</span> <span class="sy0">+</span> d.<span class="me1">toTimeString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        res.<span class="me1">setContent</span><span class="br0">&#40;</span>str<span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span><span class="sy0">,</span>
    save <span class="sy0">=</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        Y.<span class="me1">StorageLite</span>.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'storage-lite:ready'</span><span class="sy0">,</span> <span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
            <span class="kw2">var</span> html <span class="sy0">=</span> editor.<span class="me1">saveHTML</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
            Y.<span class="me1">StorageLite</span>.<span class="me1">setItem</span><span class="br0">&#40;</span><span class="st0">'editorContent'</span><span class="sy0">,</span> html<span class="br0">&#41;</span><span class="sy0">;</span>
            <span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">'Editor content saved..'</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw2">var</span> editor <span class="sy0">=</span> <span class="kw2">new</span> YAHOO.<span class="me1">widget</span>.<span class="me1">Editor</span><span class="br0">&#40;</span><span class="st0">'editor'</span><span class="sy0">,</span> <span class="br0">&#123;</span>
        dompath<span class="sy0">:</span> <span class="kw2">true</span><span class="sy0">,</span>
        width<span class="sy0">:</span> <span class="st0">'550px'</span><span class="sy0">,</span>
        height<span class="sy0">:</span> <span class="st0">'250px'</span><span class="sy0">,</span>
        toolbar<span class="sy0">:</span> <span class="br0">&#123;</span>
            titlebar<span class="sy0">:</span> <span class="st0">'Saving Editor'</span><span class="sy0">,</span>
            buttons<span class="sy0">:</span> <span class="br0">&#91;</span>
                <span class="br0">&#123;</span> group<span class="sy0">:</span> <span class="st0">'saveclear'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Save &amp; Clear'</span><span class="sy0">,</span>
                    buttons<span class="sy0">:</span> <span class="br0">&#91;</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Save'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'save'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Clear'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'clear'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Reset'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'reset'</span> <span class="br0">&#125;</span>
                    <span class="br0">&#93;</span>
                <span class="br0">&#125;</span><span class="sy0">,</span>
                <span class="br0">&#123;</span> group<span class="sy0">:</span> <span class="st0">'textstyle'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Font Style'</span><span class="sy0">,</span>
                    buttons<span class="sy0">:</span> <span class="br0">&#91;</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Bold'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'bold'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Italic'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'italic'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'push'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Underline'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'underline'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'separator'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'select'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Arial'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'fontname'</span><span class="sy0">,</span> disabled<span class="sy0">:</span> <span class="kw2">true</span><span class="sy0">,</span>
                            menu<span class="sy0">:</span> <span class="br0">&#91;</span>
                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Arial'</span><span class="sy0">,</span> checked<span class="sy0">:</span> <span class="kw2">true</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Arial Black'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Comic Sans MS'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Courier New'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Lucida Console'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Tahoma'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Times New Roman'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Trebuchet MS'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                                <span class="br0">&#123;</span> text<span class="sy0">:</span> <span class="st0">'Verdana'</span> <span class="br0">&#125;</span>
                            <span class="br0">&#93;</span>
                        <span class="br0">&#125;</span><span class="sy0">,</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'spin'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'13'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'fontsize'</span><span class="sy0">,</span> range<span class="sy0">:</span> <span class="br0">&#91;</span> <span class="nu0">9</span><span class="sy0">,</span> <span class="nu0">75</span> <span class="br0">&#93;</span><span class="sy0">,</span> disabled<span class="sy0">:</span> <span class="kw2">true</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'separator'</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'color'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Font Color'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'forecolor'</span><span class="sy0">,</span> disabled<span class="sy0">:</span> <span class="kw2">true</span> <span class="br0">&#125;</span><span class="sy0">,</span>
                        <span class="br0">&#123;</span> type<span class="sy0">:</span> <span class="st0">'color'</span><span class="sy0">,</span> label<span class="sy0">:</span> <span class="st0">'Background Color'</span><span class="sy0">,</span> value<span class="sy0">:</span> <span class="st0">'backcolor'</span><span class="sy0">,</span> disabled<span class="sy0">:</span> <span class="kw2">true</span> <span class="br0">&#125;</span>
                    <span class="br0">&#93;</span>
                <span class="br0">&#125;</span>
            <span class="br0">&#93;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    editor.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'toolbarLoaded'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        editor.<span class="me1">toolbar</span>.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'clearClick'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
            editor.<span class="me1">setEditorHTML</span><span class="br0">&#40;</span><span class="st0">'&lt;br&gt;'</span><span class="br0">&#41;</span><span class="sy0">;</span>
            <span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">'Editor content cleared..'</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        editor.<span class="me1">toolbar</span>.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'resetClick'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
            <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">confirm</span><span class="br0">&#40;</span><span class="st0">'Are you sure you want to reset the Editor?'</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                editor.<span class="me1">setEditorHTML</span><span class="br0">&#40;</span>defaultText<span class="br0">&#41;</span><span class="sy0">;</span>
                Y.<span class="me1">StorageLite</span>.<span class="me1">setItem</span><span class="br0">&#40;</span><span class="st0">'editorContent'</span><span class="sy0">,</span> <span class="kw2">null</span><span class="br0">&#41;</span><span class="sy0">;</span>
                <span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">'Editor content reset to default..'</span><span class="br0">&#41;</span><span class="sy0">;</span>
            <span class="br0">&#125;</span>
        <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        editor.<span class="me1">toolbar</span>.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'saveClick'</span><span class="sy0">,</span> save<span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    Y.<span class="me1">later</span><span class="br0">&#40;</span><span class="nu0">5000</span><span class="sy0">,</span> editor<span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw1">if</span> <span class="br0">&#40;</span>editor.<span class="me1">editorDirty</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
            editor.<span class="me1">editorDirty</span> <span class="sy0">=</span> <span class="kw2">null</span><span class="sy0">;</span>
            save<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span><span class="sy0">,</span> <span class="br0">&#123;</span><span class="br0">&#125;</span><span class="sy0">,</span> <span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span>
    Y.<span class="me1">StorageLite</span>.<span class="me1">on</span><span class="br0">&#40;</span><span class="st0">'storage-lite:ready'</span><span class="sy0">,</span> <span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">var</span> editorValue <span class="sy0">=</span> Y.<span class="me1">StorageLite</span>.<span class="me1">getItem</span><span class="br0">&#40;</span><span class="st0">'editorContent'</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="kw1">if</span> <span class="br0">&#40;</span>editorValue <span class="sy0">!==</span> <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
            Y.<span class="me1">one</span><span class="br0">&#40;</span><span class="st0">'#editor'</span><span class="br0">&#41;</span>.<span class="me1">set</span><span class="br0">&#40;</span><span class="st0">'value'</span><span class="sy0">,</span> editorValue<span class="br0">&#41;</span><span class="sy0">;</span>
            <span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">'Loaded editor content from Local Storage'</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
            <span class="kw1">write</span><span class="br0">&#40;</span><span class="st0">'Loaded default editor content'</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
        editor.<span class="me1">render</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
&nbsp;</pre></div><textarea id="syntax-d637e0fd7a315aab60d36f2178ced3cc-plain">YUI().use('node', 'gallery-storage-lite', 'yui2-editor', function(Y) {

    //Aliasing Y.YUI2 to YAHOO
    var YAHOO = Y.YUI2, res = Y.one('#wrapper .status'),
    defaultText = Y.one('#editor').get('value'),
    write = function(str) {
        var d = new Date();
        str += ' :: ' + d.toTimeString();
        res.setContent(str);
    },
    save = function() {
        Y.StorageLite.on('storage-lite:ready', function () {
            var html = editor.saveHTML();
            Y.StorageLite.setItem('editorContent', html);
            write('Editor content saved..');
        });
    };

    var editor = new YAHOO.widget.Editor('editor', {
        dompath: true,
        width: '550px',
        height: '250px',
        toolbar: {
            titlebar: 'Saving Editor',
            buttons: [
                { group: 'saveclear', label: 'Save & Clear',
                    buttons: [
                        { type: 'push', label: 'Save', value: 'save' },
                        { type: 'push', label: 'Clear', value: 'clear' },
                        { type: 'push', label: 'Reset', value: 'reset' }
                    ]
                },
                { group: 'textstyle', label: 'Font Style',
                    buttons: [
                        { type: 'push', label: 'Bold', value: 'bold' },
                        { type: 'push', label: 'Italic', value: 'italic' },
                        { type: 'push', label: 'Underline', value: 'underline' },
                        { type: 'separator' },
                        { type: 'select', label: 'Arial', value: 'fontname', disabled: true,
                            menu: [
                                { text: 'Arial', checked: true },
                                { text: 'Arial Black' },
                                { text: 'Comic Sans MS' },
                                { text: 'Courier New' },
                                { text: 'Lucida Console' },
                                { text: 'Tahoma' },
                                { text: 'Times New Roman' },
                                { text: 'Trebuchet MS' },
                                { text: 'Verdana' }
                            ]
                        },
                        { type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ], disabled: true },
                        { type: 'separator' },
                        { type: 'color', label: 'Font Color', value: 'forecolor', disabled: true },
                        { type: 'color', label: 'Background Color', value: 'backcolor', disabled: true }
                    ]
                }
            ]
        }
    });
    editor.on('toolbarLoaded', function() {
        editor.toolbar.on('clearClick', function() {
            editor.setEditorHTML('<br>');
            write('Editor content cleared..');
        });
        editor.toolbar.on('resetClick', function() {
            if (confirm('Are you sure you want to reset the Editor?')) {
                editor.setEditorHTML(defaultText);
                Y.StorageLite.setItem('editorContent', null);
                write('Editor content reset to default..');
            }
        });
        editor.toolbar.on('saveClick', save);
    });
    Y.later(5000, editor, function() {
        if (editor.editorDirty) {
            editor.editorDirty = null;
            save();
        }
    }, {}, true);
    Y.StorageLite.on('storage-lite:ready', function () {
        var editorValue = Y.StorageLite.getItem('editorContent');
        if (editorValue !== null) {
            Y.one('#editor').set('value', editorValue);
            write('Loaded editor content from Local Storage');
        } else {
            write('Loaded default editor content');
        }
        editor.render();
    });
});

</textarea></div>
				</div>
				<div class="yui-u sidebar">
	
					<div id="examples" class="mod box4">
                        <div class="hd">
						<h4>
    The YUI Global Object Examples:</h4>
                        </div>
						<div class="bd">
							<ul>
								<li><a href='../yui/yui-core.html'>YUI Core</a></li><li><a href='../yui/yui-more.html'>Load All Modules</a></li><li><a href='../yui/yui-multi.html'>Multiple Instances</a></li><li><a href='../yui/yui-loader-ext.html'>YUI Loader - Dynamically Adding YUI and External Modules</a></li><li><a href='../yui/yui-extend.html'>Create Class Hierarchies with <code>extend</code></a></li><li><a href='../yui/yui-augment.html'>Compose Classes of Objects with <code>augment</code></a></li><li><a href='../yui/yui-mix.html'>Add Behaviors to Objects with <code>mix</code></a></li><li><a href='../yui/yui-merge.html'>Combine Data Sets with <code>merge</code></a></li><li><a href='../yui/yui-isa.html'>Check Data Types with <code>Lang</code></a></li><li><a href='../yui/yui-ua.html'>Browser Detection with <code>UA</code></a></li><li><a href='../yui/yui-compat.html'>YUI 2 in 3</a></li><li><a href='../yui/yui-gallery.html'>Natively use YUI Gallery Modules</a></li><li class='selected'><a href='../yui/yui-gallery2.html'>YUI 2 in 3 &amp; Gallery Modules</a></li>							</ul>
						</div>
					</div>

					<div class="mod box4">
                        <div class="hd">
						<h4>More The YUI Global Object Resources:</h4>
                        </div>
                        <div class="bd">
						<ul>
							<!-- <li><a href="http://developer.yahoo.com/yui/yui/">User's Guide</a> (external)</li> -->
<li><a href="../../api/module_yui.html">API Documentation</a></li></ul>
                        </div>
					</div>
			  </div>
		</div>

		</div>
	</div>


<div class="yui-b toc3" id="tocWrapper">
<!-- TABLE OF CONTENTS -->
<div id="toc">
	
<ul>
<li class="sect first">YUI 3 Resources</li><li class="item"><a title="YUI 3 -- Yahoo! User Interface (YUI) Library" href="http://developer.yahoo.com/yui/3/">YUI 3 Web Site</a></li><li class="item"><a title="Examples of every YUI utility and control in action" href="../../examples/">YUI 3 Examples</a></li><li class="item"><a title="Instantly searchable API documentation for the entire YUI library." href="../../api/">YUI 3 API Docs</a></li><li class="item"><a title="YUI 3 Dependency Configurator -- configure your custom YUI implementation" href="http://developer.yahoo.com/yui/3/configurator/index.html">YUI 3 Dependency Configurator</a></li><li class="item"><a title="The YUI 3 Forum on YUILibrary.com" href="http://yuilibrary.com/forum/viewforum.php?f=15">YUI 3 Forums (external)</a></li><li class="item"><a title="Found a bug or a missing feature? Let us know on YUILibrary.com." href="http://developer.yahoo.com/yui/articles/reportingbugs/">Bug Reports/Feature Requests</a></li><li class="item"><a title="YUI is free and open, offered under a BSD license." href="http://developer.yahoo.com/yui/license.html">YUI License</a></li><li class="item"><a title="Download and fork the YUI project on GitHub" href="http://github.com/yui">YUI on Github</a></li><li class="item"><a title="The Yahoo! User Interface Blog" href="http://yuiblog.com">YUI Blog (external)</a></li><li class="sect">YUI 3 Core - Examples</li><li class="selected "><a title="YUI Global Object - Functional Examples" href="../../examples/yui/index.html">YUI Global Object</a></li><li class="item"><a title="Event - Functional Examples" href="../../examples/event/index.html">Event</a></li><li class="item"><a title="Node - Functional Examples" href="../../examples/node/index.html">Node</a></li><li class="sect">YUI 3 Component Infrastructure - Examples</li><li class="item"><a title="Attribute - Functional Examples" href="../../examples/attribute/index.html">Attribute</a></li><li class="item"><a title="Plugin - Functional Examples" href="../../examples/plugin/index.html">Plugin</a></li><li class="item"><a title="Widget - Functional Examples" href="../../examples/widget/index.html">Widget</a></li><li class="sect">YUI 3 Utilities - Examples</li><li class="item"><a title="Animation - Functional Examples" href="../../examples/anim/index.html">Animation</a></li><li class="item"><a title="AsyncQueue - Functional Examples" href="../../examples/async-queue/index.html">AsyncQueue</a></li><li class="item"><a title="Cache - Functional Examples" href="../../examples/cache/index.html">Cache</a></li><li class="item"><a title="Cookie - Functional Examples" href="../../examples/cookie/index.html">Cookie</a></li><li class="item"><a title="DataSchema - Functional Examples" href="../../examples/dataschema/index.html">DataSchema <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="DataSource - Functional Examples" href="../../examples/datasource/index.html">DataSource <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="DataType - Functional Examples" href="../../examples/datatype/index.html">DataType <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Drag &amp; Drop - Functional Examples" href="../../examples/dd/index.html">Drag &amp; Drop</a></li><li class="item"><a title="Get - Functional Examples" href="../../examples/get/index.html">Get</a></li><li class="item"><a title="History - Functional Examples" href="../../examples/history/index.html">History <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="IO - Functional Examples" href="../../examples/io/index.html">IO</a></li><li class="item"><a title="ImageLoader - Functional Examples" href="../../examples/imageloader/index.html">ImageLoader</a></li><li class="item"><a title="Internationalization - Functional Examples" href="../../examples/intl/index.html">Internationalization</a></li><li class="item"><a title="JSON (JavaScript Object Notation) - Functional Examples" href="../../examples/json/index.html">JSON</a></li><li class="item"><a title="JSONP (JSON with Padding) - Functional Examples" href="../../examples/jsonp/index.html">JSONP <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Recordset - Functional Examples" href="../../examples/recordset/index.html">Recordset <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Resize - Functional Examples" href="../../examples/resize/index.html">Resize <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Sortable - Functional Examples" href="../../examples/sortable/index.html">Sortable <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Stylesheet - Functional Examples" href="../../examples/stylesheet/index.html">Stylesheet</a></li><li class="item"><a title="Transition - Functional Examples" href="../../examples/transition/index.html">Transition <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Uploader - Functional Examples" href="../../examples/uploader/index.html">Uploader <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="YQL Query - Functional Examples" href="../../examples/yql/index.html">YQL Query <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="sect">YUI 3 Widgets - Examples</li><li class="item"><a title="AutoComplete - Functional Examples" href="../../examples/autocomplete/index.html">AutoComplete <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Charts - Functional Examples" href="../../examples/charts/index.html">Charts <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="DataTable - Functional Examples" href="../../examples/datatable/index.html">DataTable <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Dial - Functional Examples" href="../../examples/dial/index.html">Dial <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Editor - Functional Examples" href="../../examples/editor/index.html">Editor <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Overlay - Functional Examples" href="../../examples/overlay/index.html">Overlay <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="ScrollView - Functional Examples" href="../../examples/scrollview/index.html">ScrollView <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Slider - Functional Examples" href="../../examples/slider/index.html">Slider <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="TabView - Functional Examples" href="../../examples/tabview/index.html">TabView <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="sect">YUI 3 Node Plugins - Examples</li><li class="item"><a title="FocusManager Node Plugin - Functional Examples" href="../../examples/node-focusmanager/index.html">FocusManager Node Plugin <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="MenuNav Node Plugin - Functional Examples" href="../../examples/node-menunav/index.html">MenuNav Node Plugin <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="sect">YUI 3 CSS - Examples</li><li class="item"><a title="YUI Base - Functional Examples" href="../../examples/cssbase/index.html">CSS Base</a></li><li class="item"><a title="YUI Fonts - Functional Examples" href="../../examples/cssfonts/index.html">CSS Fonts</a></li><li class="item"><a title="YUI Grids - Functional Examples" href="../../examples/cssgrids/index.html">CSS Grids <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="YUI CSS Reset - Functional Examples" href="../../examples/cssreset/index.html">CSS Reset</a></li><li class="sect">YUI 3 Developer Tools - Examples</li><li class="item"><a title="Console - Functional Examples" href="../../examples/console/index.html">Console <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Console Filters Plugin- Functional Examples" href="../../examples/console-filters/index.html">Plugin.ConsoleFilters <img alt='beta' src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Profiler - Functional Examples" href="../../examples/profiler/index.html">Profiler</a></li><li class="item"><a title="Test - Functional Examples" href="../../examples/test/index.html">Test</a></li><li class="sect">Other Useful YUI 3 Resources</li><li class="item"><a title="Answers to Frequently Asked Questions about the YUI Library" href="http://developer.yahoo.com/yui/articles/faq/">YUI FAQ (external)</a></li><li class="item"><a title="Yahoo!'s philosophy of Graded Browser Support" href="http://developer.yahoo.com/yui/articles/gbs/">Graded Browser Support (external)</a></li><li class="item"><a title="Videos and podcasts from the YUI Team and from the Yahoo! frontend engineering community." href="http://developer.yahoo.com/yui/theater/">YUI Theater (external)</a></li></ul>
</div>
</div>
	</div><!--closes bd-->

	<div id="ft">
        <p class="first">Copyright &copy; 2011 Yahoo! Inc. All rights reserved.</p>
        <p><a href="http://privacy.yahoo.com/privacy/us/devel/index.html">Privacy Policy</a> - 
            <a href="http://docs.yahoo.com/info/terms/">Terms of Service</a> - 
            <a href="http://docs.yahoo.com/info/copyright/copyright.html">Copyright Policy</a> - 
            <a href="http://careers.yahoo.com/">Job Openings</a></p>
	</div>
</div>
<script language="javascript"> 
var yuiConfig = {filter:"debug", logInclude: {"example":true, "gallery-storage-lite":true}};
</script>
<script src="../../assets/syntax.js"></script>
<script src="../../assets/dpSyntaxHighlighter.js"></script>
<script language="javascript"> 
dp.SyntaxHighlighter.HighlightAll('code'); 
</script>
</body>
</html>
